package logic

import (
	"context"
	"month/videosvr/internal/service"
	"time"

	"month/videosvr/internal/svc"
	"month/videosvr/video"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoListLogic {
	return &VideoListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// VideoList todo 笔记列表展示
func (l *VideoListLogic) VideoList(in *video.VideoListReq) (*video.VideoListRes, error) {
	// todo: add your logic here and delete this line
	timeData := time.Now().Add(time.Hour * 24 * -7)
	t := timeData.Format(time.DateTime)
	//todo 查询
	res, err := service.GetVideoList(t)
	//todo 数据处理
	var list []*video.VideoAll
	for _, v := range res {
		var data = &video.VideoAll{
			Like:    v.LikeCount,
			Look:    v.LookCount,
			Comment: v.CommentCount,
			Cang:    v.CangCount,
			Barrage: v.BarrageCount,
			Send:    v.SendCount,
		}
		list = append(list, data)
	}
	if err != nil {
		return &video.VideoListRes{}, err
	}
	return &video.VideoListRes{
		Data:  list,
		Page:  2,
		Count: 8,
	}, nil
}
